package com.junzhiit.nengji.shop.model.enums;

import com.bainaeco.framework.exception.InvalidArgumentException;

public enum TargetType {
	
	LOGIN(0,"授权登录"),
	TOTAL_CONSUME(1,"累计消费"),
	RECHARGE(2,"一次性充值"),
	TOTAL_INTEGRAL(3,"累计积分");
	
	private Integer type;
	
	private String value;

	private TargetType(Integer status,String value){
		this.type = status;
		this.value = value;
	}

	public int toIntType() {
		return this.type;
	}
	
	public String toStringValue() {
		return this.value;
	}

	public static TargetType toFlag(int type) {
		if (LOGIN.type == type) {
			return LOGIN;
		} else if (TOTAL_CONSUME.type == type) {
			return TOTAL_CONSUME;
		} else if (RECHARGE.type == type) {
			return RECHARGE;
		} else if (TOTAL_INTEGRAL.type == type) {
			return TOTAL_INTEGRAL;
		} else {
			throw new InvalidArgumentException("Unknown type[" + type + "].");
		}
	}
}
